package com.spring.xenon.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.codehaus.jackson.map.util.JSONPObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.spring.security.core.util.ApplicationUtils;
import com.spring.xenon.web.service.MenuService;

@Controller
@RequestMapping(value = "/xenon")
public class XenonController {
	
	@Resource
	private MenuService menuService;
	

	@RequestMapping(value = "/index")
	public ModelAndView index(HttpServletRequest request) {
		Map<String, Object> retD = new HashMap<String, Object>();
		retD.put("menu", menuService.createMenu(null));
		return new ModelAndView("main/index",retD);
	}
	
	@RequestMapping(value = "/frame")
	public ModelAndView frame(HttpServletRequest request) {
		return new ModelAndView("main/frame");
	}

	// 跳转到xenon首页
//	@RequestMapping(value = "/getMenuStr")
//	public ModelAndView getMenuStr(HttpServletRequest request) {
//		Map<String, Object> retD = new HashMap<String, Object>();
//		retD.put("menu", menuService.createMenu());
//		return new ModelAndView("xenon/xenon", retD);
//	}

	@RequestMapping(value = "/getDataTest")
	@ResponseBody
	public Object getBaseCodeList(String type, HttpServletRequest request,
			String callback) {
		Map<String, Object> m = menuService.getDataList();
		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/xenonFirst")
	public ModelAndView xenonFirst(HttpServletRequest request) {
		return new ModelAndView("main/first");
	}
	
	@RequestMapping(value = "/xenonSec")
	public ModelAndView xenonSec(HttpServletRequest request) {
		return new ModelAndView("main/sec");
	}
	
	@RequestMapping(value = "/xenonThree")
	public ModelAndView xenonThree(HttpServletRequest request) {
		return new ModelAndView("main/three");
	}
}
